package com.lehecai.core.api.event;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhangzq on 14-11-14.
 */
public class EventType extends IntegerBeanLabelItem {

    private static final Logger logger = LoggerFactory.getLogger(PropType.class.getName());

    private static List<EventType> items = new ArrayList<EventType>();
    private static List<EventType> queryItems = new ArrayList<EventType>();

    protected EventType(String name, int value, boolean queryOnly) {
        super(EventType.class.getName(), name, value);
        queryItems.add(this);
        if (!queryOnly) {
            items.add(this);
        }
    }

    protected EventType(String name, int value) {
        this(name, value, false);
    }

    public static EventType getItem(int value){
        try {
            return (EventType) EventType.getResult(EventType.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    public static List<EventType> getItems() {
        return items;
    }

    public static List<EventType> getQueryItems() {
        return queryItems;
    }

    public static final EventType ALL = new EventType("全部", -1, true);
    public static final EventType EVENT_TYPE_AWARD = new EventType("送彩加奖", 1);
    public static final EventType EVENT_TYPE_DRAW = new EventType("幸运抽奖", 2);
    public static final EventType EVENT_TYPE_GAME = new EventType("趣味游戏", 3);
}
